package com.laiketui.order.controller;

import com.laiketui.common.utils.tool.cache.RedisDataTool;
import com.laiketui.core.cache.RedisUtil;
import com.laiketui.domain.user.User;
import com.laiketui.domain.vo.MainVo;
import org.jetbrains.annotations.NotNull;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;

public class BaseController {

    @Autowired
    RedisUtil redisUtil;

    @Value("${debugger.local.test:false}")
    private boolean test;

    public static void main(String[] args) {

    }

    public User getUser(MainVo vo) {
        if (test) {
            return testUser();
        }
        return RedisDataTool.getRedisUserCache(vo.getAccessId(), redisUtil, true);
    }

    private static @NotNull User testUser() {
        User user = new User();
        user.setUser_id("user943");
        user.setStore_id(1);
        user.setRole_id(379);
        user.setMobile("13359272219");
        user.setUser_name("王静");
        return user;
    }
}
